import request from "@/utils/request.ts";
import type { Patient } from "@/types/patientTypes";
import type { ResponseType } from "@/types/responseTypes";

enum Enum {
    patientList = "/patient/mylist",
    deletePatient = "/patient/del",
    addPatient = "/patient/add",
    findPatient = "/patient/info",
    editPatient = "/patient/update"
}

/*获取患者列表的接口*/
export const fetchPatientAPI = (): Promise<ResponseType<Patient[]>> => request.get<Patient[], ResponseType<Patient[]>>(Enum.patientList);
/*删除患者的接口*/
export const deletePatientAPI = (patientId: string): Promise<ResponseType<{ id: string }>> => request.delete<{ id: string }, ResponseType<{ id: string }>>(`${Enum.deletePatient}/${patientId}`);
/*添加患者的接口*/
export const addPatientAPI = (data: Patient): Promise<ResponseType<{ id: string }>> => request.post<{ id: string }, ResponseType<{ id: string }>>(Enum.addPatient, data);
/*查找患者列表的接口*/
export const findPatientAPI = (id: string): Promise<ResponseType<Patient>> => request.get<Patient, ResponseType<Patient>>(`${Enum.findPatient}/${id}`);
/*编辑患者的接口*/
export const editPatientAPI = (data: Patient): Promise<ResponseType<{ id: string }>> => request.put<{ id: string }, ResponseType<{ id: string }>>(Enum.editPatient, data);
